package com.example.kotlindemo

import android.os.Bundle
import androidx.activity.ComponentActivity
import androidx.activity.compose.setContent
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Surface
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.tooling.preview.Preview
import androidx.core.content.edit
import androidx.lifecycle.Lifecycle
import androidx.lifecycle.LifecycleOwner
import androidx.lifecycle.lifecycleScope
import com.example.kotlindemo.`interface`.Clickable2
import com.example.kotlindemo.ui.theme.KotlinDemoTheme
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.launch

open class MainActivity : ComponentActivity(),Clickable2 {

    val str1 = "abc"
    val str2 = """value1
        value2\n\t
        value3
    """.trimMargin() //Raw String


    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContent {

            KotlinDemoTheme {
                // A surface container using the 'background' color from the theme
                Surface(
                    modifier = Modifier.fillMaxSize(),
                    color = MaterialTheme.colorScheme.background
                ) {
                    ThreadUtils.onMainthread{
                        //todo
                    }
                    My.Companion.DEFAULT
                }
            }

//            view.setOnClickListener(object:View.onClick()){
//
//            }

//            view.setOnClickListener { v ->
//                ...
//            }

            //            view.setOnClickListener {
//                it.
//            }

        }


        val sp = application.getSharedPreferences("sp", MODE_PRIVATE)
        sp.edit {
            putBoolean("key",true)
        }

//        val bitmap = drawable.toBit

        lifecycleScope.launch(Dispatchers.IO) {

        }


    }


//    fun getValue(a:Int):Int{
//        return 9
//    }

    //when function
    fun getValue(a: Int) = when {
        a > 0 -> "A"
        a < 0 -> "A1"
        a.hashCode() == 0x108 -> "222"
        else -> "KK"
    }

    //java 三目
    val status  = when {

        else -> {}
    }

    override fun click() {
        TODO("Not yet implemented")
    }
}

